package learningThread.syn.synchronizedMethodLockObj.part1;

public class TestOperationObj {

    /**
     *
     * @param args
     */
    public static void main(String[] args) {
        //没有 同步， 所以执行的结果 都是交替进行的
        OperationObj operationObj = new OperationObj();
        Thread1 thread1 = new Thread1(operationObj);
        Thread2 thread2 = new Thread2(operationObj);
        thread1.setName("a");
        thread2.setName("b");
        thread1.start();
        thread2.start();


        //这个是加锁了，所以执行 c ,d 时是排队执行的 ，
        OperationObj1 operationObj1 = new OperationObj1();
        Thread3 thread3 = new Thread3(operationObj1);
        Thread4 thread4 = new Thread4(operationObj1);
        thread3.setName("c");
        thread4.setName("d");
        thread3.start();
        thread4.start();
    }
}
